Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use lint-staged correctly (to decrease commit time) #1226

Merged
merged 1 commit into from
Sep 2, 2022

Conversation

pepopowitz
Copy link
Collaborator

A Friday afternoon (my time) gift for @tmetzke:

What is the purpose of the change

Updates the pre-commit hook to run prettier against only files that have changed, for much faster commits.

How?

I was using lint-staged incorrectly! In a case of over-pursuing the DRY principle, I configured lint-staged to run npm run format, to avoid defining what "format" meant in two places.

But the format script passes . as the path to prettier, resulting in the entire codebase being formatted even for a one line change.

lint-staged passes a glob for the committed files to the configured command...this change takes advantage of that, and now the hook will only format the files being committed.

Before this change

image

After this change

image

PR Checklist

  • My changes apply to an already released version, and I have added them to the relevant /versioned_docs directory, or they are not for an already released version.
  • My changes apply to future versions, and I have added them to the main /docs directory, or they are not for future versions.
  • My changes require an Engineering review, and I've assigned an engineering manager or tech lead as a reviewer, or my changes do not require an Engineering review.
  • My changes require a technical writer review, and I've assigned @christinaausley as a reviewer, or my changes do not require a technical writer review.

It was previously running prettier against the entire codebase on commit, instead of just the files that are being committed.
@pepopowitz pepopowitz added kind/bug Issues related with bugs in the documentation component:docs Documentation improvements, including new or updated content dx Documentation infrastructure typically handled by the Camunda DX team labels Sep 2, 2022
@pepopowitz pepopowitz self-assigned this Sep 2, 2022
@pepopowitz pepopowitz enabled auto-merge (squash) September 2, 2022 17:26
@pepopowitz pepopowitz changed the title fix: use lint-staged correctly fix: use lint-staged correctly (to decrease commit time) Sep 2, 2022
Copy link
Member

@tmetzke tmetzke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is HUGE! Thanks so much, @pepopowitz, you made my weekend 👍

@pepopowitz pepopowitz merged commit fab1123 into main Sep 2, 2022
@pepopowitz pepopowitz deleted the much-faster-commits branch September 2, 2022 18:22
@akeller
Copy link
Member

akeller commented Sep 6, 2022

This is HUGE! Thanks so much, @pepopowitz, you made my weekend 👍

Ok but this comment alone turned my week around 🥰

@tmetzke
Copy link
Member

tmetzke commented Sep 6, 2022

So much love ❤️ ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:docs Documentation improvements, including new or updated content dx Documentation infrastructure typically handled by the Camunda DX team kind/bug Issues related with bugs in the documentation
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants